﻿using Admin.Models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Admin.DAL
{
    public class ProductDetailsDAL : ConnectionDB
    {
        public List<ProductDetailsModel> CTSANPHAM(string id)
        {
            List<ProductDetailsModel> list = new List<ProductDetailsModel>();
            SqlCommand command = CreateCommand("select * from CTSANPHAM");

            SqlDataReader dr;
            dr = command.ExecuteReader();
            while (dr.Read())
            {
                ProductDetailsModel pro = new ProductDetailsModel();

                pro.MASP = dr["MASP"].ToString();
                pro.IMG = dr["IMG"].ToString();
                pro.TENSP = dr["TENSP"].ToString();
                pro.GIACU = dr["GIACU"].ToString();
                pro.GIAMOI = dr["GIAMOI"].ToString();
                pro.SALEOF = dr["SALEOF"].ToString();
                pro.CHUDE = dr["CHUDE"].ToString();
                pro.NGAYTAO = dr["NGAYTAO"].ToString();
                pro.NGUOITAO = dr["NGUOITAO"].ToString();

                list.Add(pro);
            }
            Connection.Close();
            return list;
        }
        public List<ProductDetailsModel> deletePRD(string id)
        {
            List<ProductDetailsModel> list = new List<ProductDetailsModel>();
            SqlCommand command = CreateCommand("select * from CTSANPHAM where MASP='" + id + "'");
            SqlDataReader dr = command.ExecuteReader();
            while (dr.Read() == true)
            {
                ProductDetailsModel pro = new ProductDetailsModel();

                pro.MASP = dr["MASP"].ToString();
                pro.IMG = dr["IMG"].ToString();
                pro.TENSP = dr["TENSP"].ToString();
                pro.GIACU = dr["GIACU"].ToString();
                pro.GIAMOI = dr["GIAMOI"].ToString();
                pro.SALEOF = dr["SALEOF"].ToString();
                pro.CHUDE = dr["CHUDE"].ToString();
                pro.NGAYTAO = dr["NGAYTAO"].ToString();
                pro.NGUOITAO = dr["NGUOITAO"].ToString();   
                list.Add(pro);
            }
            Connection.Close();
            return list;
        }

        public List<ProductDetailsModel> editPRD(string id)
        {
            List<ProductDetailsModel> list = new List<ProductDetailsModel>();
            SqlCommand command = CreateCommand("select * from CTSANPHAM where MASP='" + id + "'");
            SqlDataReader dr = command.ExecuteReader();
            while (dr.Read() == true)
            {
                ProductDetailsModel pro = new ProductDetailsModel();

                pro.MASP = dr["MASP"].ToString();
                pro.IMG = dr["IMG"].ToString();
                pro.TENSP = dr["TENSP"].ToString();
                pro.GIACU = dr["GIACU"].ToString();
                pro.GIAMOI = dr["GIAMOI"].ToString();
                pro.SALEOF = dr["SALEOF"].ToString();
                pro.CHUDE = dr["CHUDE"].ToString();
                pro.NGAYTAO = dr["NGAYTAO"].ToString();
                pro.NGUOITAO = dr["NGUOITAO"].ToString();  
                list.Add(pro);
            }
            Connection.Close();
            return list;
        }

        public List<ProductDetailsModel> insertPRD(string id)
        {
            List<ProductDetailsModel> list = new List<ProductDetailsModel>();
            SqlCommand command = CreateCommand("select * from CTSANPHAM where MASP='" + id + "'");
            SqlDataReader dr = command.ExecuteReader();
            while (dr.Read() == true)
            {
                ProductDetailsModel pro = new ProductDetailsModel();

                pro.MASP = dr["MASP"].ToString();
                pro.IMG = dr["IMG"].ToString();
                pro.TENSP = dr["TENSP"].ToString();
                pro.GIACU = dr["GIACU"].ToString();
                pro.GIAMOI = dr["GIAMOI"].ToString();
                pro.SALEOF = dr["SALEOF"].ToString();
                pro.CHUDE = dr["CHUDE"].ToString();
                pro.NGAYTAO = dr["NGAYTAO"].ToString();
                pro.NGUOITAO = dr["NGUOITAO"].ToString();
                list.Add(pro);
            }
            Connection.Close();
            return list;
        }





    }
}